package com.ruoyi.hualian.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.hualian.domain.ImportErp;
import com.ruoyi.hualian.service.ExcelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.zip.ZipOutputStream;

/**
 * 华链测试功能接口
 *
 * @author hujian
 */
// @Api(tags = "华链测试功能接口")
@RestController
@RequestMapping("huaLian/test")
public class HuaLianTestController {

    private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);

    // @ApiOperation("GET测试")
    // @GetMapping("/getTest")
    public AjaxResult getTest() {
        log.info("Get请求测试Api接口成功");
        return AjaxResult.success("Get请求测试Api接口成功");
    }

    // @ApiOperation("POST测试")
    // @PostMapping("/postTest")
    public AjaxResult postTest(@RequestParam("str") String str, @RequestParam("string") String string) {
        log.info("POST请求测试Api接口成功-->" + str);
        log.info("POST请求测试Api接口成功-->" + string);
        return AjaxResult.success("Post请求测试Api接口成功-->" + str + "<-->" + string);
    }

    @ApiOperation("zip测试")
    @GetMapping("/zipTest")
    public AjaxResult zipTest(HttpServletResponse response) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ZipOutputStream zip = new ZipOutputStream(outputStream);
        IOUtils.closeQuietly(zip);
        // generatorCode(tableName, zip);
        byte[] byteArray = outputStream.toByteArray();
        return AjaxResult.success();
    }
    @ApiOperation("数字测试")
    @GetMapping("/nine/{num}")
    public AjaxResult nine(@PathVariable int num) {
        // 九九乘法表
        for (int i = 1; i <= num; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(j + " * " + i + " = " + (i*j) + "\t");
            }
            System.out.println();
        }
        // 金字塔
        int input = 5;
        String output = "⭐";
        int rows = input - 1;
        int k = 0;
        for (int i = 0; i < rows; i++) {
            for (int j = rows - i; j > 0; j--) {
                System.out.print("  ");
            }
            for (int j = 0; j <= k; j++) {
                System.out.print(output);
            }
            k = k + 2;
            System.out.println();
        }
        for (int j = 0; j <= k; j++) {
            System.out.print(output);
        }
        return AjaxResult.success();
    }
}
